﻿using System;

namespace Framework.UI
{
    public class UISlider : UIBase
    {
        private ExSlider mExSlider = null;

        public ExSlider ExSlider { get { return mExSlider; } }

        public Action<float> OnValueChangeBegin { get; set; }
        public Action<float> OnValueChange { get; set; }
        public Action<float> OnValueChangeEnd { get; set; }

        protected override void OnAwake()
        {
            mExSlider = GetComponent<ExSlider>("ExSlider");
            mExSlider.OnValueChangeBegin = OnValueChangeBeginSlider;
            mExSlider.onValueChanged.AddListener(OnValueChangeSlider);
            mExSlider.OnValueChangeEnd = OnValueChangeEndSlider;
        }

        private void OnValueChangeBeginSlider(float pValue)
        {
            OnValueChangeBegin?.Invoke(pValue);
        }

        private void OnValueChangeSlider(float pValue)
        {
            OnValueChange?.Invoke(pValue);
        }

        private void OnValueChangeEndSlider(float pValue)
        {
            OnValueChangeEnd?.Invoke(pValue);
        }

        #region 编辑器相关
        override protected void OnValidate()
        {
            base.OnValidate();
        }
        #endregion
    }
}